<html>
<head><meta charset="utf-8"><title>Local decls · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html">Local decls</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="182415226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182415226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182415226">(Dec 03 2019 at 04:20)</a>:</h4>
<p>I'm trying to look into <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1165" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1165">https://github.com/rust-analyzer/rust-analyzer/issues/1165</a>, and I'm trying to add <code>ModuleItem</code> to <code>Block</code>s. I've changed the grammar.ron, but where should I actually put the parsed things into the AST?</p>



<a name="182415353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182415353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182415353">(Dec 03 2019 at 04:23)</a>:</h4>
<p>Oh, is RA parsing things by trying to cast them? Then it looks like the items are naturally collected</p>



<a name="182422661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182422661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182422661">(Dec 03 2019 at 07:27)</a>:</h4>
<p><span class="user-mention" data-user-id="243635">@ice1000</span> be warned that <a href="https://github.com/rust-lang/rust/issues/1165" target="_blank" title="https://github.com/rust-lang/rust/issues/1165">#1165</a> is a rather involved issue, which requires a bit of up-front design. </p>
<p>I don't think it requires any changes on the parser level though... Rather, it probably needs:</p>
<ul>
<li>integration of <code>DefCollector</code> and <code>ExprScopes</code> into a single thing</li>
<li>ability to create these dependent <code>DefCollectors</code> for items</li>
</ul>



<a name="182458460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182458460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182458460">(Dec 03 2019 at 15:18)</a>:</h4>
<p>Yes, but the grammar.ron needs to be changed</p>



<a name="182458555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182458555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182458555">(Dec 03 2019 at 15:18)</a>:</h4>
<p>Yes, but the grammar.ron needs to be changed</p>



<a name="182458799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182458799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182458799">(Dec 03 2019 at 15:20)</a>:</h4>
<p>Oh, you are of course right, <span class="user-mention" data-user-id="243635">@ice1000</span> ! Yeah, I think we should add <code>ModuleItemOwner</code> to the list of traits that is implemented by <code>ast::Block</code>.</p>



<a name="182459194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182459194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182459194">(Dec 03 2019 at 15:24)</a>:</h4>
<p>My WIP branch is <a href="https://github.com/ice1000/rust-analyzer/tree/oxa-very-cute" target="_blank" title="https://github.com/ice1000/rust-analyzer/tree/oxa-very-cute">https://github.com/ice1000/rust-analyzer/tree/oxa-very-cute</a></p>



<a name="182459235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182459235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182459235">(Dec 03 2019 at 15:24)</a>:</h4>
<p>I'm not sure if I'm on the right direction</p>



<a name="182467883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182467883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182467883">(Dec 03 2019 at 16:37)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="133169">@matklad</span> , do you have any suggestions on the next step to take? I think I've did the def collection, but I'm not sure if the approach works. What sort of test should I add?</p>



<a name="182468913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182468913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182468913">(Dec 03 2019 at 16:45)</a>:</h4>
<p>There are like, a lot of questions</p>



<a name="182468958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182468958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182468958">(Dec 03 2019 at 16:45)</a>:</h4>
<p>The first step would be to send a PR which justs makes a <code>Block</code> an <code>ItemOwner</code></p>



<a name="182468993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182468993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182468993">(Dec 03 2019 at 16:45)</a>:</h4>
<p>And you are very right that there are many questions :)</p>



<a name="182469121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469121">(Dec 03 2019 at 16:46)</a>:</h4>
<p>I think we probably should start with something relatively simple: not trying to properly link ExprScopes and CrateDefMap, but just treating functions as a separate scope for items</p>



<a name="182469216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469216">(Dec 03 2019 at 16:47)</a>:</h4>
<p>The Module's data contains <code>AstId&lt;Module&gt;</code>, while I'm using the blocks' Ids in <code>ModuleData::Block</code></p>



<a name="182469304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469304">(Dec 03 2019 at 16:48)</a>:</h4>
<p>I'm having stacktraces when running ra on my computer</p>



<a name="182469312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469312">(Dec 03 2019 at 16:48)</a>:</h4>
<p>Where should I send them</p>



<a name="182469346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469346">(Dec 03 2019 at 16:48)</a>:</h4>
<p>Cus ra is paralyzed now, I can't even navigate</p>



<a name="182469347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469347">(Dec 03 2019 at 16:48)</a>:</h4>
<p>I think this can work like this:</p>
<ul>
<li>we add <code>ModuleScope</code> field to <code>Body</code></li>
<li>when lowering the <code>Body</code>, we also populate module scope (here, we completely ignore the fact that block scope is also important)</li>
<li>in the <code>Resolver</code>, we take this Body's <code>ModuleScope</code> into account</li>
</ul>



<a name="182469436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469436">(Dec 03 2019 at 16:49)</a>:</h4>
<p>Is it even possible to restart ra?</p>



<a name="182469461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469461">(Dec 03 2019 at 16:49)</a>:</h4>
<p><span class="user-mention" data-user-id="243635">@ice1000</span> there's "reload window" action in VS Code</p>



<a name="182469495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469495">(Dec 03 2019 at 16:50)</a>:</h4>
<p>And also <code>Rust Analyzer: restart server</code></p>



<a name="182469537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469537">(Dec 03 2019 at 16:50)</a>:</h4>
<blockquote>
<p>I'm having stacktraces when running ra on my computer</p>
</blockquote>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/issues/2467" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/2467">https://github.com/rust-analyzer/rust-analyzer/issues/2467</a> ? maybe check that you're on newest master</p>



<a name="182469570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469570">(Dec 03 2019 at 16:50)</a>:</h4>
<p>I am</p>



<a name="182469620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469620">(Dec 03 2019 at 16:51)</a>:</h4>
<p>I've <code>cargo xtask install --server</code> 10 minutes ago after my PR gets merged</p>



<a name="182469631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469631">(Dec 03 2019 at 16:51)</a>:</h4>
<p>Another option is to properly design this merging of crate def map and bodies, and do the right thing from the start... But I personally don't have a design blueprint in my hand for this</p>



<a name="182469685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469685">(Dec 03 2019 at 16:51)</a>:</h4>
<p>Oh my god it's my own change that causes the panicking</p>



<a name="182469703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469703">(Dec 03 2019 at 16:51)</a>:</h4>
<p><span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="182469814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469814">(Dec 03 2019 at 16:52)</a>:</h4>
<p>It says <code>thread '&lt;unnamed&gt;' panicked at 'Can't find BLOCK@[1031; 1053) in AstIdMap</code>, which probably because I was adding things like blocks' Ids to the database but it's somehow not collected</p>



<a name="182469892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469892">(Dec 03 2019 at 16:53)</a>:</h4>
<blockquote>
<p>Another option is to properly design this merging of crate def map and bodies, and do the right thing from the start... But I personally don't have a design blueprint in my hand for this</p>
</blockquote>
<p>yeah, I feel like we need to start experimenting before we'll come up with a proper design :)</p>



<a name="182469963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469963">(Dec 03 2019 at 16:54)</a>:</h4>
<p>I think that's what I'm doing</p>



<a name="182469971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469971">(Dec 03 2019 at 16:54)</a>:</h4>
<p>I mean, "merging of crate def map and bodies"</p>



<a name="182469989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182469989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182469989">(Dec 03 2019 at 16:54)</a>:</h4>
<p>Starting experimentation is not a problem. Finishing it properly is the hard bit :)</p>



<a name="182470026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182470026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182470026">(Dec 03 2019 at 16:55)</a>:</h4>
<p>Do I PR for unfinished features?</p>



<a name="182470084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182470084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182470084">(Dec 03 2019 at 16:55)</a>:</h4>
<p>Like, is it preferred to send small PRs about the nonbreaking things added before the big thing launches</p>



<a name="182470268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182470268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182470268">(Dec 03 2019 at 16:57)</a>:</h4>
<p><span class="user-mention" data-user-id="243635">@ice1000</span> it depends. If it's a self-contained thing which will be needed <em>regardless</em> of the final direction the feature takes, than it's best to send it in a separate PR, however small it is. For example, adding <code>ModuleItemsOwner</code> trait to <code>Block</code> is an example of such change. </p>
<p>On the other hand, for something bigger, which represent a part of <em>possible</em>, but not unique path to the solution, it's better to send something which has user-visible effects and can be tested</p>



<a name="182470354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182470354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182470354">(Dec 03 2019 at 16:58)</a>:</h4>
<p>Ok that sounds cool, I'll PR right after rust analyzer compiles</p>



<a name="182470436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182470436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182470436">(Dec 03 2019 at 16:59)</a>:</h4>
<p>The metric here is that we want to minimize the size of PR (there's no such thing as too small a PR), <em>but</em> we want to make sure that the merged code actually works: it's to easy to start building something. only to realise later that it can't possible work</p>



<a name="182471001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471001">(Dec 03 2019 at 17:04)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/2471" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/2471">https://github.com/rust-analyzer/rust-analyzer/pull/2471</a></p>



<a name="182471442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471442">(Dec 03 2019 at 17:08)</a>:</h4>
<p>looks liek the correct trait name is <code>ModuleItemOwner</code></p>



<a name="182471450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471450">(Dec 03 2019 at 17:08)</a>:</h4>
<p>Just fixed</p>



<a name="182471488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471488">(Dec 03 2019 at 17:08)</a>:</h4>
<p>Cool, rust analyzer starts working again</p>



<a name="182471534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471534">(Dec 03 2019 at 17:09)</a>:</h4>
<p>I have seen some tabs mixed along with the spaces, and I changed them all to spaces</p>



<a name="182471865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471865">(Dec 03 2019 at 17:12)</a>:</h4>
<p><a href="/user_uploads/4715/QRUBXaEPpr3WEx1Y9Z4t8a6m/pasted_image.png" target="_blank" title="pasted_image.png">pasted image</a> This resolution is really weird</p>
<div class="message_inline_image"><a href="/user_uploads/4715/QRUBXaEPpr3WEx1Y9Z4t8a6m/pasted_image.png" target="_blank" title="pasted image"><img src="/user_uploads/4715/QRUBXaEPpr3WEx1Y9Z4t8a6m/pasted_image.png"></a></div>



<a name="182471878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471878">(Dec 03 2019 at 17:13)</a>:</h4>
<p>Is it a known bug?</p>



<a name="182471938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471938">(Dec 03 2019 at 17:13)</a>:</h4>
<p>I think that's and index-based fallback: if we can't resolve the name properly, we just pick any declaration with a matching naming, in hope that it would be corrct</p>



<a name="182471977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182471977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182471977">(Dec 03 2019 at 17:14)</a>:</h4>
<p>so, it's a "feature"</p>



<a name="182472166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182472166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182472166">(Dec 03 2019 at 17:16)</a>:</h4>
<p>It's a bug because the really correct result is not resolved</p>



<a name="182472184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182472184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182472184">(Dec 03 2019 at 17:16)</a>:</h4>
<p>The wrong resolution result is a feature</p>



<a name="182477342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182477342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182477342">(Dec 03 2019 at 18:02)</a>:</h4>
<p>Seem like we still not implement   <code>std::ops::Index</code> handling yet.</p>



<a name="182477970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182477970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182477970">(Dec 03 2019 at 18:08)</a>:</h4>
<p>I'm not sure about some compilation failures in <a href="https://github.com/ice1000/rust-analyzer/tree/114514" target="_blank" title="https://github.com/ice1000/rust-analyzer/tree/114514">https://github.com/ice1000/rust-analyzer/tree/114514</a>, can anyone take a look? I'm trying to change <code>ModuleData.declaration &amp; definition</code> pair into a three-state enum, <code>ModuleOrigin</code> (with one more state, as my ongoing PR will support block level modules), but that requires me to implement <code>Default</code> for it, while I don't know how.</p>



<a name="182478236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182478236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182478236">(Dec 03 2019 at 18:11)</a>:</h4>
<p>Something like <code>trait `std::convert::From&lt;&amp;ra_db::input::FileId&gt;` is not implemented for `ra_hir_expand::HirFileId</code></p>



<a name="182478253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182478253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182478253">(Dec 03 2019 at 18:11)</a>:</h4>
<p><code>self.def_map.modules[module_id].definition = Some(file_id)</code></p>



<a name="182478683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182478683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182478683">(Dec 03 2019 at 18:15)</a>:</h4>
<p><span class="user-mention" data-user-id="243635">@ice1000</span> Add an enum variant  in ModuleOrigin to indicate it is empty and make it default ?</p>



<a name="182479438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182479438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182479438">(Dec 03 2019 at 18:23)</a>:</h4>
<p>Or change to :</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="n">origin</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="n">ModuleOrigin</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
</pre></div>



<a name="182482605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182482605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182482605">(Dec 03 2019 at 18:54)</a>:</h4>
<p>I wonder if the <code>Default</code> trait is really used</p>



<a name="182482826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182482826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182482826">(Dec 03 2019 at 18:56)</a>:</h4>
<p>It's used only twice</p>



<a name="182483461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182483461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182483461">(Dec 03 2019 at 19:03)</a>:</h4>
<p>I got it. It's the root module that is initialized <em>after</em> (or during? Not sure) collecting def</p>



<a name="182489184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182489184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182489184">(Dec 03 2019 at 20:00)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/2473" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/2473">https://github.com/rust-analyzer/rust-analyzer/pull/2473</a></p>



<a name="182493694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182493694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182493694">(Dec 03 2019 at 20:50)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/2474" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/2474">https://github.com/rust-analyzer/rust-analyzer/pull/2474</a></p>



<a name="182496300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182496300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182496300">(Dec 03 2019 at 21:13)</a>:</h4>
<p>If you admins prefer taking 2474 directly, then feel free to close 2473</p>



<a name="182497054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182497054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182497054">(Dec 03 2019 at 21:19)</a>:</h4>
<p>I've closed 2473 myself</p>



<a name="182518736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182518736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182518736">(Dec 04 2019 at 02:23)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> could you please take a look at this code <a href="https://github.com/ice1000/rust-analyzer/commit/541eb7e12e948058e8efa563f303828b3bebb713#diff-f26837190e672b2e01be4ca7511e50f8L535" target="_blank" title="https://github.com/ice1000/rust-analyzer/commit/541eb7e12e948058e8efa563f303828b3bebb713#diff-f26837190e672b2e01be4ca7511e50f8L535">https://github.com/ice1000/rust-analyzer/commit/541eb7e12e948058e8efa563f303828b3bebb713#diff-f26837190e672b2e01be4ca7511e50f8L535</a>? I essentially added <code>block_id</code> to <code>FunctionLoc</code>, and try to find the (block-level anonymous) module corresponds to the <code>block_id</code>. This is making tests to fail, and I have no idea what's going on.</p>



<a name="182519103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182519103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182519103">(Dec 04 2019 at 02:30)</a>:</h4>
<p>I'm like dying, debugging &amp; refactoring rust analyzer is just so hard</p>



<a name="182528001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182528001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182528001">(Dec 04 2019 at 05:54)</a>:</h4>
<p>I have made a "reviewable webpage" aka an in-fork pull request (<a href="https://github.com/ice1000/rust-analyzer/pull/1/files" target="_blank" title="https://github.com/ice1000/rust-analyzer/pull/1/files">https://github.com/ice1000/rust-analyzer/pull/1/files</a>) to show the change after the rust-analyzer pull request.</p>



<a name="182659574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/182659574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#182659574">(Dec 05 2019 at 13:39)</a>:</h4>
<p>Ok, finally got 2474 done</p>



<a name="183713674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Local%20decls/near/183713674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ice1000 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Local.20decls.html#183713674">(Dec 18 2019 at 02:27)</a>:</h4>
<p>Anyone wanna take this on</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>